;;打开init.el
(defun open-init-file()
  (interactive)
  (find-file (concat my-root-dir "/init.el")))

;;注释
(defun my-comment-or-uncomment-region (beg end &optional arg)
  (interactive (if (use-region-p)
                   (list (region-beginning) (region-end) nil)
                 (list (line-beginning-position)
                       (line-beginning-position 2))))
  (comment-or-uncomment-region beg end arg))


;;绑定
(global-set-key (kbd "<f2>") 'open-init-file)

(global-set-key (kbd "C-<tab>") 'dabbrev-expand)
(define-key minibuffer-local-map (kbd "C-<tab>") 'dabbrev-expand)

(global-set-key (kbd "C-c C-/") 'my-comment-or-uncomment-region)

(global-set-key "\C-s" 'swiper)
(global-set-key (kbd "C-c C-r") 'ivy-resume)
(global-set-key (kbd "M-x") 'counsel-M-x)
(global-set-key (kbd "C-x C-f") 'counsel-find-file)

;;窗口切换
(global-set-key (kbd "C-c j") 'windmove-up)
(global-set-key (kbd "C-c k") 'windmove-down)
(global-set-key (kbd "C-c h") 'windmove-left)
(global-set-key (kbd "C-c l") 'windmove-right)

;;设置 set-mark-command
(global-set-key (kbd "M-/") 'set-mark-command)

(provide 'init-keybinds)
